

 const ImageChooseMixin = {
	data() {
		return {
			uploadedImage: "",
			// 当前进行的步骤 -1：未选择图片  1：选择图片未开始处理 
			step: -1,
			loading: false,
		}
	},
	methods: {
		// 选择图片
		handleChooseImage() {
			const _this = this;
		    uni.showActionSheet({
		        itemList: ['从相册选择', '拍照'],
		        itemColor: '#007aff',
		        success: (res) => {
		            const sourceType = res.tapIndex === 0 ? ['album'] : ['camera'];
		            uni.chooseImage({
		                count: 1,
		                sourceType: sourceType,
		                success: (res) => {
		                    this.uploadedImage = res.tempFilePaths[0];
							this.beforeSrc = this.uploadedImage;
							this.afterSrc = "";
							this.step = 1;
		                    // 跳转到处理页面并传递图片路径
		                    // uni.navigateTo({
		                    //     url: `/pages/Processing/Processing?imagePath=${this.uploadedImage}&title=${item.title}&key=${item.key}`
		                    // });
		                },
		                fail: (err) => {
		                    console.error('选择图片失败:', err);
							this.step = -1;
		                }
		            });
		        },
		        fail: (err) => {
		            console.error('显示操作菜单失败:', err);
		        }
		    });
		},
	}
}

export default ImageChooseMixin;